Source code for src.cmd.activate
import os, sys
from contextlib import closing
from ..configuration import config
def activate(cmd):
[docs] """The activate command allows a user to set the current working project.
To illustrate, if example_project_1 is the current working project and the user would like to switch to
example_project_2 they would run the following command.
>>> cchrrd activate -n example_project_2
example_project_2 has been activated and is the current project.
"""
args = cmd.args
path = os.path.join(__file__, '..', '..', '..', 'project_data', 'current_project.txt')
project_path = os.path.join(args.root_dir)
if args.name not in [f for f in os.listdir(project_path)]:
print 'Unable to locate project: %s in %s' % (args.name, project_path)
sys.exit(1)
with closing(open(path, 'wb')) as file:
_ = os.path.join(project_path, args.name, '%s.config' % args.name)
file.write(os.path.normpath(_))
print '%s has been activated and is the current project.' % args.name